<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<title></title>
	<meta name="format-detection" content="telephone=no"/>
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../css/list.css" />
</head>
<body>
	<div class="h10"></div>	  
	<div id="main_content">
	
		<!--<div class="main_content">
			<div class="cnt">
				<div class="wrap">
					<div class="wrap2"><div class="content">
					<div class="shopname">的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概的gags大概</div>
					<div class="suggestion">这是一个新闻下的 是是</div>
				       	<div class="info"><span class="symbol">试试</span>
				       	<span class="price">2015-05-05 55 55 55</span></div></div></div></div></div></div>-->
	
	</div>
  	<div id="divNoDataTip">
		<div id="textTip" style="margin-top:10px;margin-bottom:10px;width:100%;text-align: center;" 
			class="button red" tapmode="">正在加载..</div>
	</div> 
	<div class="h10"></div>
	<input id="pageIndex" type="hidden" value="0"/>
	<input id="pageSize" type="hidden" value="20"/>
</body>
<script type="text/javascript" src="../script/api.js"></script>  
<script type="text/javascript" src="../script/alpenlicebe.js"></script>   
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script> 
<script>
	apiready = function(){ 
		var obj = api.require('inputField');
    	obj.open({
	    		bgColor:'#f0f0f0',
	        	lineColor:'#cdcdcd',
	         	fileBgColor:'#fff',
	       		borderColor:'#cdcdcd',
	         	placeholder:'请输入内容',
	          	sendImg:'widget://image/btn/submit.png'
       		},function(ret,err) {
      			if(ret.msg){
            		goto_sendMsgFun(ret.msg);
          		}else{
          			api.alert({msg:"内容不能为空!"});
        		}
     	}); 
 		/*下拉刷新*/
    	api.setRefreshHeaderInfo({
            visible: true,
            loadingImg: 'widget://image/refresh.png',
            bgColor: '#fff',
            textColor: '#000',
            textDown: '下拉刷新...',
            textUp: '松开刷新...',
            showTime: true
        }, function (ret, err) { 
        	$("#pageIndex").val(0); 
        	$("#main_content").html(""); 
        	$("#textTip").html("正在加载..");
            goto_loadDataFun();
            api.refreshHeaderLoadDone();
        }); 
       	/*滑动到底部加载数据*/
   		api.addEventListener({name: 'scrolltobottom'}, function (ret, err) {
            goto_loadDataFun();
        });  
        
        /*初始化加载数据*/
       	goto_loadDataFun();   
	}  
	
    function goto_loadDataFun() {  
        goto_loadNewsListFun(); 
        api.parseTapmode();  
    } 
	function goto_loadNewsListFun(){ 
		var userID=Alpe_getLocalStorge('access_token');  
    	if(''==userID){
    		api.alert({title:'系统提示',msg:'您未登录'});
			return;
    	}
    	var infoID=api.pageParam.infoID;
		if(''==infoID||undefined==infoID||null==infoID){
    		api.alert({title:'系统提示',msg:'参数错误'});
			return;
    	}
		var pageIndex=parseInt($("#pageIndex").val())+1;
		var pageSize=$("#pageSize").val();
		$("#pageIndex").val(pageIndex);
		 
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    title: '',
		    text: '',
		    modal: false
		});
		
		var MD5 = new Hashes.MD5;   
       	var access_token = Alpe_getLocalStorge("access_token");                     
       	var admin_id = Alpe_getLocalStorge("admin_id"); 
       	var sign = MD5.hex(access_token+admin_id+pageIndex+'datas/GetSpecialMsgInfo'+infoID+'1.0syjqingbao');
       	var url = Alpe_ApiUrl+'r=datas/GetSpecialMsgInfo&access_token='+access_token+'&admin_id='+admin_id
       		+'&page='+pageIndex+'&special_id='+infoID
       		+'&v=1.0&sign='+sign;
       		//console.log(url);
       	api.ajax({
	         url: url,
	         method: 'get',
	         cache: false,
	         timeout: 30,			
	         dataType: 'json'
       	}, function(ret, err){
			if (ret) {	 
				if(ret.success == '100'){ 
					if(ret.list.length<pageSize){
						api.removeEventListener({name:'scrolltobottom'}); 
                 		$("#textTip").html("暂无更多数据");
					} 
					$.each(ret.list, function (index, v) {		
						var str='';
						if(v.newsTitle!=''){
							if(v.newsID!=''){
								str='<div class="suggestion"><a onclick="goto_openDetailWinFun('+v.newsID+')">'+v.newsTitle+'</a></div>';
							}else{
								str='<div class="suggestion"><a onclick="void(0)">'+v.newsTitle+'</a></div>';
							}
						}	
						var tmpHtml = '<div class="main_content" tapmode="presshover"><div class="cnt"><div class="wrap"><div class="wrap2">'
				  			+'<div class="content"><div style="word-break: break-all; word-wrap:break-word;" class="shopname">'+v.content
				  			+'</div>'+str+'<div class="info"><span class="symbol">'+v.username
				  			+'</span><span class="price">'+v.inputtime+'</span></div></div></div></div></div></div>';
				  			       
				       	/*var tmpHtml = '<div class="main_content"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div style="width:100%" class="shopname">'+v.content
				       		+'</div>'+str+'<div class="info"><span class="symbol">'+v.username
				       		+'</span><span class="price">'+v.inputtime+'</span></div></div></div></div></div></div>';
				  		*/
				  		$("#main_content").append(tmpHtml);
				  	}); 	 
				}else if("002"==ret.success||"003"==ret.success){ 
					goto_openWin_loginWin(ret.message);
				}else{	
					api.removeEventListener({name:'scrolltobottom'}); 
                 	$("#textTip").html(ret.message);			 
					api.toast({
		         		msg: ret.message,
                 		duration:2000,
                    	location: 'middle'
               		});         
		  		}
		  		api.hideProgress(); 
			}else{
				api.alert({title:'系统提示',msg:'错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode});
				api.hideProgress();
			} 
   		});
	} 
	function goto_sendMsgFun(msg){
		var infoID=api.pageParam.infoID;
		if(''==infoID||undefined==infoID||null==infoID){
    		api.alert({title:'系统提示',msg:'参数错误'});
			return;
    	}
    	api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    title: '',
		    text: '',
		    modal: false
		});
		
		var MD5 = new Hashes.MD5;   
       	var access_token = Alpe_getLocalStorge("access_token");                     
       	var admin_id = Alpe_getLocalStorge("admin_id"); 
       	var sign = MD5.hex(access_token+admin_id+'0'+pageIndex+'datas/GetSpecialSubmitMsg'+infoID+'1.0syjqingbao');
       	var url = Alpe_ApiUrl+'r=datas/GetSpecialSubmitMsg&access_token='+access_token+'&admin_id='+admin_id
       		+'newsID=0&page='+pageIndex+'&special_id='+infoID+'&message='+msg
       		+'&v=1.0&sign='+sign;
       	api.ajax({
	         url: url,
	         method: 'get',
	         cache: false,
	         timeout: 30,			
	         dataType: 'json'
       	}, function(ret, err){
			if (ret) {	 
				api.toast({
	         		msg: ret.message,
             		duration:2000,
                	location: 'middle'
           		}); 
		  		api.hideProgress();
		  		$("#pageIndex").val(0); 
	        	$("#main_content").html(""); 
	        	$("#textTip").html("正在加载..");
	            goto_loadDataFun();
			}else{
				api.alert({title:'系统提示',msg:'错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode});
				api.hideProgress();
			} 
   		});
	}
	function goto_openDetailWinFun(infoID){   
		var hotID=api.pageParam.infoID;
	
		Alpe_setLocalStorge('sys_tempID_'+infoID,infoID);
 		$("#newTitleID_"+infoID).css('color','#999');    		    
		var delay = 0; 
	 	if("ios" != api.systemType){
	    	delay = 300;
	  	}
  		api.openWin({
            name: 'hot_TrackListInfoListDetail',
            url: './hot_TrackListInfoListDetail.html',
            bounces: false,
            reload: true,
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto'
            },
            pageParam: {infoID:infoID,hotID:hotID},
            delay: delay
   		}); 	 	 
	} 
</script>
</html>